
const fs = require('fs');

module.exports = app => {
  try {
    // 读取当前目录，获取文件名并加载模块
    fs.readdirSync(__dirname).forEach(name => {
      if (name !== 'index.js') {
        const route = require(`./${name}`);
        app.use(route.routes()).use(route.allowedMethods())
      }
    })
  } catch (err) {
    throw err
  }
}